package com.zhuiyun.educations.api.subject.mapper;

import com.zhuiyun.educations.api.subject.entity.Subject;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @ClassName SubjectMapper
 * @Description TODO 父科目持久层
 * @Author 杨友朋
 * @Date 2023/6/19 14:55
 **/
@Mapper
public interface SubjectMapper {

    /**
     * @Author 杨友朋
     * @Description TODO 全查父科目
     * @Date 2023/6/21 20:21
     * @Return List<Subject>
     * @param subject
     */
    @Select("select * from subject where del_flag=0")
    List<Subject> selectSubject(Subject subject);

    /**
     * @Author 杨友朋
     * @Description TODO 添加父科目
     * @Date 2023/6/21 20:22
     * @Return Integer
     * @param subject
     */
    @Insert("insert into subject (subject_type,create_time,update_time) " +
            "values (#{subjectType},#{createTime},#{updateTime})")
    Integer insertSubject(Subject subject);

    /**
     * @Author 杨友朋
     * @Description TODO 根据id删除父科目
     * @Date 2023/6/21 20:23
     * @Return Integer
     * @param id
     */
    @Update("update subject set del_flag=1 where id=#{id}")
    Integer deleteSubjectById(Integer id);

    /**
     * @Author 杨友朋
     * @Description TODO 根据ids批量删除父目录
     * @Date 2023/6/21 20:24
     * @Return Integer
     * @param ids
     */
    @Update("<script>" +
            "update subject set del_flag=1 where id IN " +
            " <foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
            "            #{id}" +
            "        </foreach>" +
            "</script>")
    Integer deleteSubjectByIds(@Param(value = "ids") List<Integer> ids);
}
